package com.artist.service.Impl;


import com.artist.entity.TbMessage;
import com.artist.mapper.MsgMapper;
import com.artist.service.MsgService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.List;
@Service("msgService")
public class MsgServiceImpl implements MsgService {
    @Autowired
    private MsgMapper msgMapper;
    @Override
    public List<TbMessage> allMessage() {

        Example example= new Example(TbMessage.class);
        Example.Criteria criteria= example.createCriteria();
        criteria.toString();
        example.orderBy("mCreatAt").desc();
        List<TbMessage> list =msgMapper.selectByExample(example);


        return list;
    }

    @Override
    public TbMessage selectMessageById(Long mId) {
        return msgMapper.selectByPrimaryKey(mId);
    }

    @Override
    public void saveMessage(TbMessage message) {
        msgMapper.insertSelective(message);

    }

    @Override
    public void updateMessage(TbMessage message) {
        msgMapper.updateByPrimaryKeySelective(message);

    }

    @Override
    public int deleteMessage(Long mId) {

        return msgMapper.deleteByPrimaryKey(mId);
    }
}
